
#line 1 "src/network/ragel_uri.rl"
/* -*-c-*- */
/* This file is part of liberis
 *
 * Copyright (C) 2008 by LScube team <team@streaming.polito.it>
 * See AUTHORS for more details
 *
 * liberis is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * liberis is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with liberis.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

#include <config.h>
#include <string.h>
#include "uri.h"


#line 79 "src/network/ragel_uri.rl"


static void append_to_string(gpointer data, gpointer user_data)
{
    GString *path = (GString*)user_data;
    char *segment = (char *)data;
    g_string_append_printf(path, "/%s", segment);
}

static void segment_free(gpointer data, ATTR_UNUSED gpointer unused)
{
    g_free(data);
}

/**
 * @brief Parse and split an URI string into an URI structure
 *
 * @param uri_string The URI string to parse and split
 *
 * @return A pointer to a newly-allocated URI structure.
 *
 * This function parses an URI, as defined by RFC1738, and splits it
 * into its components in the given structure.
 */
URI *uri_parse(const char *uri_string)
{
    const char *p = uri_string, *pe = p + strlen(p) + 1, *mark;
    GQueue *stack = g_queue_new();
    URI *uri = g_slice_new0(URI);
    int cs;

    
#line 63 "src/network/ragel_uri.c"
static const char _uri_parser_actions[] = {
	0, 1, 0, 1, 1, 1, 2, 1, 
	3, 1, 4, 1, 5, 1, 6, 1, 
	7, 2, 0, 2, 2, 0, 3, 2, 
	0, 4, 2, 0, 7, 2, 3, 1, 
	2, 4, 1, 2, 5, 1, 2, 7, 
	1, 2, 8, 1, 3, 0, 3, 1, 
	3, 0, 4, 1, 3, 0, 7, 1, 
	3, 0, 8, 1
};

static const short _uri_parser_key_offsets[] = {
	0, 0, 4, 14, 26, 41, 53, 65, 
	71, 77, 83, 89, 104, 119, 125, 131, 
	144, 157, 163, 169, 184, 202, 219, 225, 
	231, 251, 265, 271, 277, 294, 310, 316, 
	322, 328, 334, 343, 350, 357, 364, 365, 
	372, 379, 386, 393, 394, 401, 408, 415, 
	422, 423, 430, 437, 444, 451, 452, 459, 
	466, 473, 480, 481, 488, 495, 502, 509, 
	510, 520, 528, 533, 534, 539, 540, 545, 
	546, 551, 554, 557, 563, 566, 569, 572, 
	578, 581, 584, 587, 593, 596, 603, 610, 
	611, 618, 625, 632, 639, 647, 655, 663, 
	674, 684, 692, 700, 707, 714, 724, 733, 
	741, 749, 751, 757, 766, 775, 784, 796, 
	807, 816, 825, 833, 843, 852, 860, 868, 
	870, 879, 888, 897, 906, 918, 929, 938, 
	947, 955, 965, 974, 982, 990, 992, 1001, 
	1010, 1019, 1028, 1040, 1051, 1060, 1069, 1077, 
	1087, 1096, 1104, 1112, 1114, 1123, 1132, 1141, 
	1150, 1162, 1173, 1182, 1191, 1199, 1209, 1218, 
	1226, 1234, 1236, 1245, 1254, 1263, 1272, 1284, 
	1295, 1304, 1313, 1321, 1322, 1332, 1341, 1349, 
	1357, 1359, 1368, 1377, 1386, 1395, 1407, 1418, 
	1427, 1436, 1444, 1450, 1457, 1470, 1484, 1504
};

static const char _uri_parser_trans_keys[] = {
	65, 90, 97, 122, 43, 58, 45, 46, 
	48, 57, 65, 90, 97, 122, 33, 37, 
	47, 61, 95, 126, 36, 59, 64, 90, 
	97, 122, 0, 33, 35, 37, 47, 61, 
	63, 95, 126, 36, 59, 64, 90, 97, 
	122, 0, 33, 37, 61, 95, 126, 36, 
	59, 63, 90, 97, 122, 0, 33, 37, 
	61, 95, 126, 36, 59, 63, 90, 97, 
	122, 48, 57, 65, 70, 97, 102, 48, 
	57, 65, 70, 97, 102, 48, 57, 65, 
	70, 97, 102, 48, 57, 65, 70, 97, 
	102, 0, 33, 35, 37, 47, 61, 63, 
	95, 126, 36, 59, 64, 90, 97, 122, 
	0, 33, 35, 37, 47, 61, 63, 95, 
	126, 36, 59, 64, 90, 97, 122, 48, 
	57, 65, 70, 97, 102, 48, 57, 65, 
	70, 97, 102, 0, 33, 35, 37, 61, 
	95, 126, 36, 59, 63, 90, 97, 122, 
	0, 33, 35, 37, 61, 95, 126, 36, 
	59, 63, 90, 97, 122, 48, 57, 65, 
	70, 97, 102, 48, 57, 65, 70, 97, 
	102, 0, 33, 35, 37, 47, 61, 63, 
	95, 126, 36, 59, 64, 90, 97, 122, 
	0, 33, 35, 37, 47, 58, 61, 63, 
	64, 91, 95, 126, 36, 59, 65, 90, 
	97, 122, 0, 33, 35, 37, 47, 58, 
	61, 63, 64, 95, 126, 36, 59, 65, 
	90, 97, 122, 48, 57, 65, 70, 97, 
	102, 48, 57, 65, 70, 97, 102, 0, 
	33, 35, 37, 47, 61, 63, 64, 95, 
	126, 36, 46, 48, 57, 58, 59, 65, 
	90, 97, 122, 33, 37, 61, 64, 95, 
	126, 36, 46, 48, 59, 65, 90, 97, 
	122, 48, 57, 65, 70, 97, 102, 48, 
	57, 65, 70, 97, 102, 0, 33, 35, 
	37, 47, 58, 61, 63, 91, 95, 126, 
	36, 59, 65, 90, 97, 122, 0, 33, 
	35, 37, 47, 58, 61, 63, 95, 126, 
	36, 59, 65, 90, 97, 122, 48, 57, 
	65, 70, 97, 102, 48, 57, 65, 70, 
	97, 102, 0, 35, 47, 63, 48, 57, 
	0, 35, 47, 63, 48, 57, 58, 86, 
	118, 48, 57, 65, 70, 97, 102, 58, 
	48, 57, 65, 70, 97, 102, 58, 48, 
	57, 65, 70, 97, 102, 58, 48, 57, 
	65, 70, 97, 102, 58, 58, 48, 57, 
	65, 70, 97, 102, 58, 48, 57, 65, 
	70, 97, 102, 58, 48, 57, 65, 70, 
	97, 102, 58, 48, 57, 65, 70, 97, 
	102, 58, 58, 48, 57, 65, 70, 97, 
	102, 58, 48, 57, 65, 70, 97, 102, 
	58, 48, 57, 65, 70, 97, 102, 58, 
	48, 57, 65, 70, 97, 102, 58, 58, 
	48, 57, 65, 70, 97, 102, 58, 48, 
	57, 65, 70, 97, 102, 58, 48, 57, 
	65, 70, 97, 102, 58, 48, 57, 65, 
	70, 97, 102, 58, 58, 48, 57, 65, 
	70, 97, 102, 58, 48, 57, 65, 70, 
	97, 102, 58, 48, 57, 65, 70, 97, 
	102, 58, 48, 57, 65, 70, 97, 102, 
	58, 58, 48, 57, 65, 70, 97, 102, 
	58, 48, 57, 65, 70, 97, 102, 58, 
	48, 57, 65, 70, 97, 102, 58, 48, 
	57, 65, 70, 97, 102, 58, 48, 49, 
	50, 58, 51, 57, 65, 70, 97, 102, 
	46, 58, 48, 57, 65, 70, 97, 102, 
	48, 49, 50, 51, 57, 46, 48, 49, 
	50, 51, 57, 46, 48, 49, 50, 51, 
	57, 93, 0, 35, 47, 58, 63, 93, 
	48, 57, 93, 48, 57, 53, 93, 48, 
	52, 54, 57, 93, 48, 53, 46, 48, 
	57, 46, 48, 57, 46, 53, 48, 52, 
	54, 57, 46, 48, 53, 46, 48, 57, 
	46, 48, 57, 46, 53, 48, 52, 54, 
	57, 46, 48, 53, 58, 48, 57, 65, 
	70, 97, 102, 58, 48, 57, 65, 70, 
	97, 102, 58, 58, 48, 57, 65, 70, 
	97, 102, 93, 48, 57, 65, 70, 97, 
	102, 93, 48, 57, 65, 70, 97, 102, 
	93, 48, 57, 65, 70, 97, 102, 46, 
	58, 48, 57, 65, 70, 97, 102, 46, 
	58, 48, 57, 65, 70, 97, 102, 46, 
	58, 48, 57, 65, 70, 97, 102, 46, 
	53, 58, 48, 52, 54, 57, 65, 70, 
	97, 102, 46, 58, 48, 53, 54, 57, 
	65, 70, 97, 102, 46, 58, 48, 57, 
	65, 70, 97, 102, 46, 58, 48, 57, 
	65, 70, 97, 102, 93, 48, 57, 65, 
	70, 97, 102, 58, 48, 57, 65, 70, 
	97, 102, 48, 49, 50, 93, 51, 57, 
	65, 70, 97, 102, 46, 58, 93, 48, 
	57, 65, 70, 97, 102, 58, 93, 48, 
	57, 65, 70, 97, 102, 58, 93, 48, 
	57, 65, 70, 97, 102, 58, 93, 48, 
	57, 65, 70, 97, 102, 46, 58, 93, 
	48, 57, 65, 70, 97, 102, 46, 58, 
	93, 48, 57, 65, 70, 97, 102, 46, 
	58, 93, 48, 57, 65, 70, 97, 102, 
	46, 53, 58, 93, 48, 52, 54, 57, 
	65, 70, 97, 102, 46, 58, 93, 48, 
	53, 54, 57, 65, 70, 97, 102, 46, 
	58, 93, 48, 57, 65, 70, 97, 102, 
	46, 58, 93, 48, 57, 65, 70, 97, 
	102, 58, 93, 48, 57, 65, 70, 97, 
	102, 48, 49, 50, 93, 51, 57, 65, 
	70, 97, 102, 46, 58, 93, 48, 57, 
	65, 70, 97, 102, 58, 93, 48, 57, 
	65, 70, 97, 102, 58, 93, 48, 57, 
	65, 70, 97, 102, 58, 93, 48, 49, 
	50, 51, 57, 65, 70, 97, 102, 46, 
	58, 93, 48, 57, 65, 70, 97, 102, 
	46, 58, 93, 48, 57, 65, 70, 97, 
	102, 46, 58, 93, 48, 57, 65, 70, 
	97, 102, 46, 53, 58, 93, 48, 52, 
	54, 57, 65, 70, 97, 102, 46, 58, 
	93, 48, 53, 54, 57, 65, 70, 97, 
	102, 46, 58, 93, 48, 57, 65, 70, 
	97, 102, 46, 58, 93, 48, 57, 65, 
	70, 97, 102, 58, 93, 48, 57, 65, 
	70, 97, 102, 48, 49, 50, 93, 51, 
	57, 65, 70, 97, 102, 46, 58, 93, 
	48, 57, 65, 70, 97, 102, 58, 93, 
	48, 57, 65, 70, 97, 102, 58, 93, 
	48, 57, 65, 70, 97, 102, 58, 93, 
	48, 49, 50, 51, 57, 65, 70, 97, 
	102, 46, 58, 93, 48, 57, 65, 70, 
	97, 102, 46, 58, 93, 48, 57, 65, 
	70, 97, 102, 46, 58, 93, 48, 57, 
	65, 70, 97, 102, 46, 53, 58, 93, 
	48, 52, 54, 57, 65, 70, 97, 102, 
	46, 58, 93, 48, 53, 54, 57, 65, 
	70, 97, 102, 46, 58, 93, 48, 57, 
	65, 70, 97, 102, 46, 58, 93, 48, 
	57, 65, 70, 97, 102, 58, 93, 48, 
	57, 65, 70, 97, 102, 48, 49, 50, 
	93, 51, 57, 65, 70, 97, 102, 46, 
	58, 93, 48, 57, 65, 70, 97, 102, 
	58, 93, 48, 57, 65, 70, 97, 102, 
	58, 93, 48, 57, 65, 70, 97, 102, 
	58, 93, 48, 49, 50, 51, 57, 65, 
	70, 97, 102, 46, 58, 93, 48, 57, 
	65, 70, 97, 102, 46, 58, 93, 48, 
	57, 65, 70, 97, 102, 46, 58, 93, 
	48, 57, 65, 70, 97, 102, 46, 53, 
	58, 93, 48, 52, 54, 57, 65, 70, 
	97, 102, 46, 58, 93, 48, 53, 54, 
	57, 65, 70, 97, 102, 46, 58, 93, 
	48, 57, 65, 70, 97, 102, 46, 58, 
	93, 48, 57, 65, 70, 97, 102, 58, 
	93, 48, 57, 65, 70, 97, 102, 48, 
	49, 50, 93, 51, 57, 65, 70, 97, 
	102, 46, 58, 93, 48, 57, 65, 70, 
	97, 102, 58, 93, 48, 57, 65, 70, 
	97, 102, 58, 93, 48, 57, 65, 70, 
	97, 102, 58, 93, 48, 49, 50, 51, 
	57, 65, 70, 97, 102, 46, 58, 93, 
	48, 57, 65, 70, 97, 102, 46, 58, 
	93, 48, 57, 65, 70, 97, 102, 46, 
	58, 93, 48, 57, 65, 70, 97, 102, 
	46, 53, 58, 93, 48, 52, 54, 57, 
	65, 70, 97, 102, 46, 58, 93, 48, 
	53, 54, 57, 65, 70, 97, 102, 46, 
	58, 93, 48, 57, 65, 70, 97, 102, 
	46, 58, 93, 48, 57, 65, 70, 97, 
	102, 58, 93, 48, 57, 65, 70, 97, 
	102, 58, 48, 49, 50, 93, 51, 57, 
	65, 70, 97, 102, 46, 58, 93, 48, 
	57, 65, 70, 97, 102, 58, 93, 48, 
	57, 65, 70, 97, 102, 58, 93, 48, 
	57, 65, 70, 97, 102, 58, 93, 48, 
	49, 50, 51, 57, 65, 70, 97, 102, 
	46, 58, 93, 48, 57, 65, 70, 97, 
	102, 46, 58, 93, 48, 57, 65, 70, 
	97, 102, 46, 58, 93, 48, 57, 65, 
	70, 97, 102, 46, 53, 58, 93, 48, 
	52, 54, 57, 65, 70, 97, 102, 46, 
	58, 93, 48, 53, 54, 57, 65, 70, 
	97, 102, 46, 58, 93, 48, 57, 65, 
	70, 97, 102, 46, 58, 93, 48, 57, 
	65, 70, 97, 102, 58, 93, 48, 57, 
	65, 70, 97, 102, 48, 57, 65, 70, 
	97, 102, 46, 48, 57, 65, 70, 97, 
	102, 33, 36, 61, 95, 126, 38, 46, 
	48, 59, 65, 90, 97, 122, 33, 36, 
	61, 93, 95, 126, 38, 46, 48, 59, 
	65, 90, 97, 122, 0, 33, 35, 37, 
	47, 61, 63, 64, 95, 126, 36, 46, 
	48, 57, 58, 59, 65, 90, 97, 122, 
	0
};

static const char _uri_parser_single_lengths[] = {
	0, 0, 2, 6, 9, 6, 6, 0, 
	0, 0, 0, 9, 9, 0, 0, 7, 
	7, 0, 0, 9, 12, 11, 0, 0, 
	10, 6, 0, 0, 11, 10, 0, 0, 
	4, 4, 3, 1, 1, 1, 1, 1, 
	1, 1, 1, 1, 1, 1, 1, 1, 
	1, 1, 1, 1, 1, 1, 1, 1, 
	1, 1, 1, 1, 1, 1, 1, 1, 
	4, 2, 3, 1, 3, 1, 3, 1, 
	5, 1, 1, 2, 1, 1, 1, 2, 
	1, 1, 1, 2, 1, 1, 1, 1, 
	1, 1, 1, 1, 2, 2, 2, 3, 
	2, 2, 2, 1, 1, 4, 3, 2, 
	2, 2, 0, 3, 3, 3, 4, 3, 
	3, 3, 2, 4, 3, 2, 2, 2, 
	3, 3, 3, 3, 4, 3, 3, 3, 
	2, 4, 3, 2, 2, 2, 3, 3, 
	3, 3, 4, 3, 3, 3, 2, 4, 
	3, 2, 2, 2, 3, 3, 3, 3, 
	4, 3, 3, 3, 2, 4, 3, 2, 
	2, 2, 3, 3, 3, 3, 4, 3, 
	3, 3, 2, 1, 4, 3, 2, 2, 
	2, 3, 3, 3, 3, 4, 3, 3, 
	3, 2, 0, 1, 5, 6, 10, 0
};

static const char _uri_parser_range_lengths[] = {
	0, 2, 4, 3, 3, 3, 3, 3, 
	3, 3, 3, 3, 3, 3, 3, 3, 
	3, 3, 3, 3, 3, 3, 3, 3, 
	5, 4, 3, 3, 3, 3, 3, 3, 
	1, 1, 3, 3, 3, 3, 0, 3, 
	3, 3, 3, 0, 3, 3, 3, 3, 
	0, 3, 3, 3, 3, 0, 3, 3, 
	3, 3, 0, 3, 3, 3, 3, 0, 
	3, 3, 1, 0, 1, 0, 1, 0, 
	0, 1, 1, 2, 1, 1, 1, 2, 
	1, 1, 1, 2, 1, 3, 3, 0, 
	3, 3, 3, 3, 3, 3, 3, 4, 
	4, 3, 3, 3, 3, 3, 3, 3, 
	3, 0, 3, 3, 3, 3, 4, 4, 
	3, 3, 3, 3, 3, 3, 3, 0, 
	3, 3, 3, 3, 4, 4, 3, 3, 
	3, 3, 3, 3, 3, 0, 3, 3, 
	3, 3, 4, 4, 3, 3, 3, 3, 
	3, 3, 3, 0, 3, 3, 3, 3, 
	4, 4, 3, 3, 3, 3, 3, 3, 
	3, 0, 3, 3, 3, 3, 4, 4, 
	3, 3, 3, 0, 3, 3, 3, 3, 
	0, 3, 3, 3, 3, 4, 4, 3, 
	3, 3, 3, 3, 4, 4, 5, 0
};

static const short _uri_parser_index_offsets[] = {
	0, 0, 3, 10, 20, 33, 43, 53, 
	57, 61, 65, 69, 82, 95, 99, 103, 
	114, 125, 129, 133, 146, 162, 177, 181, 
	185, 201, 212, 216, 220, 235, 249, 253, 
	257, 263, 269, 276, 281, 286, 291, 293, 
	298, 303, 308, 313, 315, 320, 325, 330, 
	335, 337, 342, 347, 352, 357, 359, 364, 
	369, 374, 379, 381, 386, 391, 396, 401, 
	403, 411, 417, 422, 424, 429, 431, 436, 
	438, 444, 447, 450, 455, 458, 461, 464, 
	469, 472, 475, 478, 483, 486, 491, 496, 
	498, 503, 508, 513, 518, 524, 530, 536, 
	544, 551, 557, 563, 568, 573, 581, 588, 
	594, 600, 603, 607, 614, 621, 628, 637, 
	645, 652, 659, 665, 673, 680, 686, 692, 
	695, 702, 709, 716, 723, 732, 740, 747, 
	754, 760, 768, 775, 781, 787, 790, 797, 
	804, 811, 818, 827, 835, 842, 849, 855, 
	863, 870, 876, 882, 885, 892, 899, 906, 
	913, 922, 930, 937, 944, 950, 958, 965, 
	971, 977, 980, 987, 994, 1001, 1008, 1017, 
	1025, 1032, 1039, 1045, 1047, 1055, 1062, 1068, 
	1074, 1077, 1084, 1091, 1098, 1105, 1114, 1122, 
	1129, 1136, 1142, 1146, 1151, 1161, 1172, 1188
};

static const unsigned char _uri_parser_indicies[] = {
	0, 0, 1, 2, 3, 2, 2, 2, 
	2, 1, 4, 5, 6, 4, 4, 4, 
	4, 4, 4, 1, 7, 4, 8, 5, 
	9, 4, 10, 4, 4, 4, 4, 4, 
	1, 11, 12, 13, 12, 12, 12, 12, 
	12, 12, 1, 14, 15, 16, 15, 15, 
	15, 15, 15, 15, 1, 17, 17, 17, 
	1, 15, 15, 15, 1, 18, 18, 18, 
	1, 4, 4, 4, 1, 7, 19, 8, 
	20, 9, 19, 10, 19, 19, 19, 19, 
	19, 1, 21, 22, 23, 24, 25, 22, 
	26, 22, 22, 22, 22, 22, 1, 27, 
	27, 27, 1, 22, 22, 22, 1, 28, 
	29, 30, 31, 29, 29, 29, 29, 29, 
	29, 1, 32, 33, 34, 35, 33, 33, 
	33, 33, 33, 33, 1, 36, 36, 36, 
	1, 33, 33, 33, 1, 7, 4, 8, 
	5, 37, 4, 10, 4, 4, 4, 4, 
	4, 1, 38, 39, 40, 41, 42, 43, 
	39, 44, 45, 46, 39, 39, 39, 39, 
	39, 1, 47, 48, 49, 50, 51, 52, 
	48, 53, 54, 48, 48, 48, 48, 48, 
	1, 55, 55, 55, 1, 48, 48, 48, 
	1, 56, 57, 58, 59, 60, 57, 62, 
	54, 57, 57, 57, 61, 57, 57, 57, 
	1, 57, 59, 57, 54, 57, 57, 57, 
	57, 57, 57, 1, 63, 63, 63, 1, 
	57, 57, 57, 1, 38, 64, 40, 65, 
	42, 66, 64, 44, 46, 64, 64, 64, 
	64, 64, 1, 47, 67, 49, 68, 51, 
	69, 67, 53, 67, 67, 67, 67, 67, 
	1, 70, 70, 70, 1, 67, 67, 67, 
	1, 56, 58, 60, 62, 71, 1, 72, 
	73, 74, 76, 75, 1, 78, 79, 79, 
	77, 77, 77, 1, 81, 80, 80, 80, 
	1, 81, 82, 82, 82, 1, 81, 83, 
	83, 83, 1, 81, 1, 85, 84, 84, 
	84, 1, 87, 86, 86, 86, 1, 87, 
	88, 88, 88, 1, 87, 89, 89, 89, 
	1, 87, 1, 91, 90, 90, 90, 1, 
	93, 92, 92, 92, 1, 93, 94, 94, 
	94, 1, 93, 95, 95, 95, 1, 93, 
	1, 97, 96, 96, 96, 1, 99, 98, 
	98, 98, 1, 99, 100, 100, 100, 1, 
	99, 101, 101, 101, 1, 99, 1, 103, 
	102, 102, 102, 1, 105, 104, 104, 104, 
	1, 105, 106, 106, 106, 1, 105, 107, 
	107, 107, 1, 105, 1, 109, 108, 108, 
	108, 1, 111, 110, 110, 110, 1, 111, 
	112, 112, 112, 1, 111, 113, 113, 113, 
	1, 111, 1, 114, 115, 116, 118, 117, 
	119, 119, 1, 120, 122, 121, 121, 121, 
	1, 123, 124, 125, 126, 1, 127, 1, 
	128, 129, 130, 131, 1, 132, 1, 133, 
	134, 135, 136, 1, 137, 1, 47, 49, 
	51, 69, 53, 1, 137, 136, 1, 137, 
	133, 1, 138, 137, 136, 133, 1, 137, 
	133, 1, 132, 131, 1, 132, 128, 1, 
	132, 139, 131, 128, 1, 132, 128, 1, 
	127, 126, 1, 127, 123, 1, 127, 140, 
	126, 123, 1, 127, 123, 1, 122, 141, 
	141, 141, 1, 122, 142, 142, 142, 1, 
	122, 1, 133, 143, 143, 143, 1, 137, 
	144, 144, 144, 1, 137, 145, 145, 145, 
	1, 137, 133, 133, 133, 1, 120, 122, 
	146, 121, 121, 1, 120, 122, 147, 141, 
	141, 1, 120, 122, 142, 142, 142, 1, 
	120, 148, 122, 146, 149, 121, 121, 1, 
	120, 122, 147, 141, 141, 141, 1, 120, 
	122, 141, 141, 141, 1, 120, 122, 149, 
	121, 121, 1, 137, 143, 143, 143, 1, 
	122, 121, 121, 121, 1, 150, 151, 152, 
	137, 153, 154, 154, 1, 120, 156, 137, 
	155, 155, 155, 1, 156, 137, 157, 157, 
	157, 1, 156, 137, 158, 158, 158, 1, 
	156, 137, 1, 143, 143, 143, 1, 120, 
	156, 137, 159, 155, 155, 1, 120, 156, 
	137, 160, 157, 157, 1, 120, 156, 137, 
	158, 158, 158, 1, 120, 161, 156, 137, 
	159, 162, 155, 155, 1, 120, 156, 137, 
	160, 157, 157, 157, 1, 120, 156, 137, 
	157, 157, 157, 1, 120, 156, 137, 162, 
	155, 155, 1, 156, 137, 155, 155, 155, 
	1, 163, 164, 165, 137, 166, 167, 167, 
	1, 120, 169, 137, 168, 168, 168, 1, 
	169, 137, 170, 170, 170, 1, 169, 137, 
	171, 171, 171, 1, 169, 137, 1, 150, 
	151, 152, 153, 154, 154, 1, 120, 169, 
	137, 172, 168, 168, 1, 120, 169, 137, 
	173, 170, 170, 1, 120, 169, 137, 171, 
	171, 171, 1, 120, 174, 169, 137, 172, 
	175, 168, 168, 1, 120, 169, 137, 173, 
	170, 170, 170, 1, 120, 169, 137, 170, 
	170, 170, 1, 120, 169, 137, 175, 168, 
	168, 1, 169, 137, 168, 168, 168, 1, 
	176, 177, 178, 137, 179, 180, 180, 1, 
	120, 182, 137, 181, 181, 181, 1, 182, 
	137, 183, 183, 183, 1, 182, 137, 184, 
	184, 184, 1, 182, 137, 1, 163, 164, 
	165, 166, 167, 167, 1, 120, 182, 137, 
	185, 181, 181, 1, 120, 182, 137, 186, 
	183, 183, 1, 120, 182, 137, 184, 184, 
	184, 1, 120, 187, 182, 137, 185, 188, 
	181, 181, 1, 120, 182, 137, 186, 183, 
	183, 183, 1, 120, 182, 137, 183, 183, 
	183, 1, 120, 182, 137, 188, 181, 181, 
	1, 182, 137, 181, 181, 181, 1, 189, 
	190, 191, 137, 192, 193, 193, 1, 120, 
	195, 137, 194, 194, 194, 1, 195, 137, 
	196, 196, 196, 1, 195, 137, 197, 197, 
	197, 1, 195, 137, 1, 176, 177, 178, 
	179, 180, 180, 1, 120, 195, 137, 198, 
	194, 194, 1, 120, 195, 137, 199, 196, 
	196, 1, 120, 195, 137, 197, 197, 197, 
	1, 120, 200, 195, 137, 198, 201, 194, 
	194, 1, 120, 195, 137, 199, 196, 196, 
	196, 1, 120, 195, 137, 196, 196, 196, 
	1, 120, 195, 137, 201, 194, 194, 1, 
	195, 137, 194, 194, 194, 1, 202, 203, 
	204, 137, 205, 206, 206, 1, 120, 208, 
	137, 207, 207, 207, 1, 208, 137, 209, 
	209, 209, 1, 208, 137, 210, 210, 210, 
	1, 208, 137, 1, 189, 190, 191, 192, 
	193, 193, 1, 120, 208, 137, 211, 207, 
	207, 1, 120, 208, 137, 212, 209, 209, 
	1, 120, 208, 137, 210, 210, 210, 1, 
	120, 213, 208, 137, 211, 214, 207, 207, 
	1, 120, 208, 137, 212, 209, 209, 209, 
	1, 120, 208, 137, 209, 209, 209, 1, 
	120, 208, 137, 214, 207, 207, 1, 208, 
	137, 207, 207, 207, 1, 215, 1, 216, 
	217, 218, 137, 219, 220, 220, 1, 120, 
	222, 137, 221, 221, 221, 1, 222, 137, 
	223, 223, 223, 1, 222, 137, 224, 224, 
	224, 1, 222, 137, 1, 202, 203, 204, 
	205, 206, 206, 1, 120, 222, 137, 225, 
	221, 221, 1, 120, 222, 137, 226, 223, 
	223, 1, 120, 222, 137, 224, 224, 224, 
	1, 120, 227, 222, 137, 225, 228, 221, 
	221, 1, 120, 222, 137, 226, 223, 223, 
	223, 1, 120, 222, 137, 223, 223, 223, 
	1, 120, 222, 137, 228, 221, 221, 1, 
	222, 137, 221, 221, 221, 1, 229, 229, 
	229, 1, 230, 229, 229, 229, 1, 231, 
	231, 231, 231, 231, 231, 231, 231, 231, 
	1, 231, 231, 231, 137, 231, 231, 231, 
	231, 231, 231, 1, 72, 57, 73, 59, 
	74, 57, 76, 54, 57, 57, 57, 232, 
	57, 57, 57, 1, 1, 0
};

static const unsigned char _uri_parser_trans_targs[] = {
	2, 0, 2, 3, 4, 9, 19, 191, 
	5, 11, 15, 191, 6, 7, 191, 6, 
	7, 8, 10, 12, 13, 191, 12, 5, 
	13, 11, 15, 14, 191, 16, 5, 17, 
	191, 16, 5, 17, 18, 20, 191, 21, 
	5, 22, 11, 24, 15, 28, 34, 191, 
	21, 5, 22, 11, 24, 15, 28, 23, 
	191, 25, 5, 26, 11, 190, 15, 27, 
	29, 30, 32, 29, 30, 32, 31, 33, 
	191, 5, 11, 33, 15, 35, 171, 186, 
	36, 39, 37, 38, 40, 157, 41, 44, 
	42, 43, 45, 143, 46, 49, 47, 48, 
	50, 129, 51, 54, 52, 53, 55, 115, 
	56, 59, 57, 58, 60, 101, 61, 64, 
	62, 63, 65, 92, 95, 98, 99, 100, 
	66, 85, 88, 67, 81, 83, 82, 68, 
	69, 77, 79, 78, 70, 71, 73, 75, 
	74, 72, 76, 80, 84, 86, 87, 89, 
	90, 91, 93, 94, 96, 97, 102, 107, 
	110, 113, 114, 103, 106, 104, 105, 108, 
	109, 111, 112, 116, 121, 124, 127, 128, 
	117, 120, 118, 119, 122, 123, 125, 126, 
	130, 135, 138, 141, 142, 131, 134, 132, 
	133, 136, 137, 139, 140, 144, 149, 152, 
	155, 156, 145, 148, 146, 147, 150, 151, 
	153, 154, 158, 163, 166, 169, 170, 159, 
	162, 160, 161, 164, 165, 167, 168, 172, 
	173, 178, 181, 184, 185, 174, 177, 175, 
	176, 179, 180, 182, 183, 187, 188, 189, 
	190
};

static const char _uri_parser_trans_actions[] = {
	1, 0, 0, 13, 0, 0, 0, 3, 
	0, 0, 0, 56, 1, 1, 41, 0, 
	0, 0, 0, 1, 1, 35, 0, 11, 
	0, 11, 11, 0, 52, 1, 26, 1, 
	38, 0, 15, 0, 0, 0, 44, 1, 
	20, 1, 20, 20, 20, 17, 1, 29, 
	0, 7, 0, 7, 7, 7, 5, 0, 
	48, 0, 23, 0, 23, 1, 23, 0, 
	1, 1, 20, 0, 0, 7, 0, 1, 
	32, 9, 9, 0, 9, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0
};

static const int uri_parser_start = 1;
static const int uri_parser_first_final = 191;
static const int uri_parser_error = 0;

static const int uri_parser_en_main = 1;


#line 111 "src/network/ragel_uri.rl"
    
#line 602 "src/network/ragel_uri.c"
	{
	cs = uri_parser_start;
	}

#line 112 "src/network/ragel_uri.rl"
    
#line 609 "src/network/ragel_uri.c"
	{
	int _klen;
	unsigned int _trans;
	const char *_acts;
	unsigned int _nacts;
	const char *_keys;

	if ( p == pe )
		goto _test_eof;
	if ( cs == 0 )
		goto _out;
_resume:
	_keys = _uri_parser_trans_keys + _uri_parser_key_offsets[cs];
	_trans = _uri_parser_index_offsets[cs];

	_klen = _uri_parser_single_lengths[cs];
	if ( _klen > 0 ) {
		const char *_lower = _keys;
		const char *_mid;
		const char *_upper = _keys + _klen - 1;
		while (1) {
			if ( _upper < _lower )
				break;

			_mid = _lower + ((_upper-_lower) >> 1);
			if ( (*p) < *_mid )
				_upper = _mid - 1;
			else if ( (*p) > *_mid )
				_lower = _mid + 1;
			else {
				_trans += (unsigned int)(_mid - _keys);
				goto _match;
			}
		}
		_keys += _klen;
		_trans += _klen;
	}

	_klen = _uri_parser_range_lengths[cs];
	if ( _klen > 0 ) {
		const char *_lower = _keys;
		const char *_mid;
		const char *_upper = _keys + (_klen<<1) - 2;
		while (1) {
			if ( _upper < _lower )
				break;

			_mid = _lower + (((_upper-_lower) >> 1) & ~1);
			if ( (*p) < _mid[0] )
				_upper = _mid - 2;
			else if ( (*p) > _mid[1] )
				_lower = _mid + 2;
			else {
				_trans += (unsigned int)((_mid - _keys)>>1);
				goto _match;
			}
		}
		_trans += _klen;
	}

_match:
	_trans = _uri_parser_indicies[_trans];
	cs = _uri_parser_trans_targs[_trans];

	if ( _uri_parser_trans_actions[_trans] == 0 )
		goto _again;

	_acts = _uri_parser_actions + _uri_parser_trans_actions[_trans];
	_nacts = (unsigned int) *_acts++;
	while ( _nacts-- > 0 )
	{
		switch ( *_acts++ )
		{
	case 0:
#line 4 "src/network/common.rl"
	{mark = p;}
	break;
	case 1:
#line 30 "src/network/ragel_uri.rl"
	{
        if ( ! g_queue_is_empty(stack) ) {
            GString *uri_path = g_string_new("");
            g_queue_foreach(stack, append_to_string, uri_path);
            uri->path = g_string_free(uri_path, FALSE);
        }
    }
	break;
	case 2:
#line 41 "src/network/ragel_uri.rl"
	{uri->userinfo = g_strndup(mark, p-mark);}
	break;
	case 3:
#line 44 "src/network/ragel_uri.rl"
	{uri->host = g_strndup(mark, p-mark);}
	break;
	case 4:
#line 46 "src/network/ragel_uri.rl"
	{uri->port = g_strndup(mark, p-mark);}
	break;
	case 5:
#line 49 "src/network/ragel_uri.rl"
	{mark = g_strndup(mark, p-mark);
                          g_queue_push_tail(stack, mark);}
	break;
	case 6:
#line 61 "src/network/ragel_uri.rl"
	{uri->scheme = g_strndup(mark, p-mark);}
	break;
	case 7:
#line 63 "src/network/ragel_uri.rl"
	{uri->query = g_strndup(mark, p-mark);}
	break;
	case 8:
#line 65 "src/network/ragel_uri.rl"
	{uri->fragment = g_strndup(mark, p-mark);}
	break;
#line 726 "src/network/ragel_uri.c"
		}
	}

_again:
	if ( cs == 0 )
		goto _out;
	if ( ++p != pe )
		goto _resume;
	_test_eof: {}
	_out: {}
	}

#line 113 "src/network/ragel_uri.rl"

    g_queue_foreach(stack, segment_free, NULL);
    g_queue_free(stack);

    if (cs < uri_parser_first_final) {
        uri_free(uri);
        return NULL;
    }

    return uri;
}
